package com.LeeCode;

/**
 * 跳跃游戏
 */
public class Code055 {
    public static void main(String[] args) {
        int[] nums = {3,2,1,0,4};
        System.out.println(new Code055().canJump(nums));
    }

    public boolean canJump(int[] nums) {
        int maxlen = 0;
        for (int i = 0; i < nums.length; i++) {
            maxlen = Math.max(maxlen, i + nums[i]);
            if(i>=maxlen || maxlen >= nums.length-1){
                break;
            }
        }
        return maxlen >= (nums.length - 1);
    }
}
